package com.example.myapplication.tack_20.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.myapplication.R;
import com.example.myapplication.tack_20.DerailsActivity;
import com.example.myapplication.tack_20.data.ArrangeData;
import com.example.myapplication.tack_20.data.ServletData;
import com.example.myapplication.utils.Common;
import com.example.myapplication.utils.OkHttpTool;

import java.util.List;

public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.My> {
    private List<ServletData.RowsDTO> list;
    private Context context;
    private View view;

    public ApplicationAdapter(List<ServletData.RowsDTO> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @NonNull
    @Override
    public My onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        view = LayoutInflater.from(context).inflate(R.layout.tack_20_servlet,null);
        return new My(view);
    }

    @Override
    public void onBindViewHolder(@NonNull My holder, int position) {

        holder.title.setText(list.get(position).getTitle());
        holder.undertaker.setText(list.get(position).getUndertaker());
        holder.requireText.setText(list.get(position).getRequireText());
        holder.startAt.setText(list.get(position).getStartAt());
        holder.bm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(context,"该活动暂时无法报名",Toast.LENGTH_SHORT).show();
            }
        });
    }

    @Override
    public int getItemCount() {
        return list != null?list.size():0;
    }

    public class My extends RecyclerView.ViewHolder{
        private TextView title;
        private TextView undertaker;
        private TextView requireText;
        private TextView startAt;
        private TextView bm;

        public My(@NonNull View itemView) {
            super(itemView);
            title = view.findViewById(R.id.title);
            undertaker = view.findViewById(R.id.undertaker);
            requireText = view.findViewById(R.id.requireText);
            startAt = view.findViewById(R.id.startAt);
            bm = view.findViewById(R.id.bm);
        }
    }
}
